//
//  UsedCarTableViewCell.m
//  WWXELuShang
//
//  Created by 王涛 on 15/12/17.
//  Copyright © 2015年 lanou. All rights reserved.
//

#import "UsedCarTableViewCell.h"
#import "UsedCar.h"
@implementation UsedCarTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //图片
        self.pictureImage = [[UIImageView alloc] initWithFrame:(CGRectMake(kWidth / 40, kHeight / 70, kWidth / 7 * 2, kHeight / 7 - kHeight / 35))];
        [self addSubview:self.pictureImage];
        //车名
        self.nameLabel = [[UILabel alloc] initWithFrame:(CGRectMake(kWidth / 3, 0, kWidth / 3 * 2 - kWidth / 40, kHeight / 7 / 3))];
        self.nameLabel.font = [UIFont boldSystemFontOfSize:15];
        [self addSubview:self.nameLabel];
        //地址
        self.dealaddrLabel = [[UILabel alloc] initWithFrame:(CGRectMake(kWidth / 3, kHeight / 21, kWidth / 3 , kHeight / 7 / 3))];
        self.dealaddrLabel.font = [UIFont systemFontOfSize:14];
        [self addSubview:self.dealaddrLabel];
        //价格
        self.priceLabel = [[UILabel alloc] initWithFrame:(CGRectMake(kWidth / 3, kHeight / 21 * 2, kWidth / 4, kHeight / 21))];
        self.priceLabel.font = [UIFont systemFontOfSize:13];
        self.priceLabel.textColor = [UIColor redColor];
        [self addSubview:self.priceLabel];

        //行驶公里
        self.mileageLabel = [[UILabel alloc] initWithFrame:(CGRectMake(kWidth * 7 / 12, kHeight / 21 * 2, kWidth - kWidth * 7 / 12 - kWidth / 40, kHeight / 21))];
        self.mileageLabel.font = [UIFont systemFontOfSize:13];
        [self addSubview:self.mileageLabel];
        
    }
    return self;
}

- (void)setUsedCar:(UsedCar *)usedCar {
    if (_usedCar != usedCar) {
        _usedCar = usedCar;
        [self.pictureImage setImageWithURL:[NSURL URLWithString:usedCar.imgurl]];
        self.nameLabel.text = usedCar.name;
        NSString *string = @"售价:";
        self.priceLabel.text = [string stringByAppendingString:usedCar.price];
        self.dealaddrLabel.text = usedCar.dealaddr;
        NSString *string1 = @"行驶里程:";
        self.mileageLabel.text = [string1 stringByAppendingString:usedCar.mileage];
        
    }
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
